ncd - Ninux Change Directory: browse & select directories
ncd [ -options ] [ directory ]
ncd is an interactive fullscreen directory browser that lets you select and change to the desired directory. It also lets you change quickly in non-interactive mode to a directory selected in the command line. ncd supports incomplete directory specification in the command line, and is able to perform automatic search in browser mode.
If you provide a directory name in the command line, ncd will run in non-interactive mode, and will try to change to the next directory that matches completely or partially the specified one.
If you don't provide a directory name in the command line, ncd will run in interactive mode. You can browse up and down the directory tree, search for a directory, and accept or cancel the selection of a directory to change to.
To get a faster response, ncd keeps a directory tree database in the user's home directory (obtained from $HOME environment variable). The database actually consists on a couple of files: .ncd_htree, that keeps the directory tree starting from the user home directory, and .ncd_ftree that keeps the full system directory tree, starting from the root directory /. All the home tree stored somewhere in the full tree file .ncd_ftree is discarded, and it is recreated based on the home tree read from .ncd_htree. In this way, the user can add/delete directories below his home directory and rebuild just the home .ncd_htree. database, avoiding to rebuild the long .ncd_free full system tree.
The program can run in two scope modes: home-scope mode or full-scope mode. In home-scope mode, only the home directory tree is available, and the program has no view of any directory external to this local tree. In full-scope mode, the full system tree starting from / is available for view and search operations. Normally the mode is automatically selected based on the current work directory at invocation time: home-scope mode is selected if the current directory is located under the home directory. Otherwise, full-scope is selected. This behaviour can be overriden using command line options. If you specify a directory in the command line (non-interactive mode) you can easily force full-scope mode starting the directory name with a slash /. This does not mean that the directory must hang from the root directory; to do this, add two slashes, except for root directory selection, that just needs one slash.
If the current work directory at invocation time is not registered in the program database files, the database (home or full depending on scope mode) is automatically rebuilt. This can be overriden using command line options.
You can supply command line options to customize some ncd actions. Options can be grouped behind a single -. You can also specify default options in the NCD_OPTS environment variable, using the same sintax as in the command line. Command line options override NCD_OPTS options.
This is a list of the supported command line options:
ncd is actually an executable binary and a shell alias or function that calls it; in this way, we can change the working directory of the current shell. The return value of the binary executable is 0 if the user has selected a valid directory. On error or if the operation has been cancelled, the program returns a value different to 0. The destination directory is returned in the file $HOME/ncd_sdir allows blind changing to the directory kept in $HOME/ncd_sdir without testing the return value of the program.
Assuming that the binary program is /usr/bin/ncd, the shell alias/function should be the following,
for the bash shell, define this function:
function ncd()
{
/usr/bin/ncd $*;
if [ $? = 0 ]; then
cd "$(cat $HOME/.ncd_sdir)";
fi
}
for the
tcsh
shell,
define this alias (here shown in two lines; actually it's just one line):
alias ncd '/usr/bin/ncd * ;
if $? == 0 cd "`cat $HOME/.ncd_sdir`" '
You can include this alias/function in your login script, or in the system wide login script. See bash(1) or tcsh(1) manpages for help on this.
$HOME/.ncd_htree home tree database.
$HOME/.ncd_ftree full tree database.
$HOME/.ncd_sdir directory selected in last execution.
Borja Etxebarria <borja@bips.bi.ehu.es>
<jtbecgob@s835cc.bi.ehu.es>
Sure a lot.
Please, report any bug or improvement to the author Include a complete, self-contained example that will allow the bug to be reproduced, and say which version of ncd you are using.
Copyright © 1995, Borja Etxebarria
Basque Country University
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.